unit UFormPrincipal;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Grids, UCelula, UPlanilha, ComCtrls;

type
  TForm1 = class(TForm)
    BtnSalvar: TBitBtn;
    BtnAdicionar: TBitBtn;
    BtnAtualizar: TBitBtn;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    BtnCarregar: TBitBtn;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    StGridDados: TStringGrid;
    StGridResultados: TStringGrid;
    Label4: TLabel;
    Label5: TLabel;
    Edit2: TEdit;
    Edit3: TEdit;
    BtnPlailha: TButton;
    BtnTransf: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure BtnAtualizarClick(Sender: TObject);
    procedure BtnSalvarClick(Sender: TObject);
    procedure BtnCarregarClick(Sender: TObject);
    procedure BtnPlailhaClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Celula1 : TCelula;
  Lista : TList;
  Planilha1 : TPlanilha;

implementation



{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Celula1 := TCelula.Create;
  Lista := TList.Create;
  Planilha1 := TPlanilha.Create;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Celula1.Free;
  Lista.Free;
  Planilha1.Free;
end;

procedure TForm1.BtnAtualizarClick(Sender: TObject);
  var x : real;
begin
  Celula1.SetValor(Edit1.Text);
  Celula1.SetTipo('valor');
  Label2.Caption := 'String: '+Celula1.GetValor;
  if Celula1.GetFloat(x)then
  Label3.Caption := 'Float: '+FloatToStr(x);
  Lista.Clear;
  Lista.Add(Celula1);
end;

procedure TForm1.BtnSalvarClick(Sender: TObject);
  var  St : TMemoryStream;
begin
  St := TMemoryStream.Create;
  Celula1.GetStream(St);
  St.Position := 0;
  St.SaveToFile('teste.str');
end;

procedure TForm1.BtnCarregarClick(Sender: TObject);
  var  St : TMemoryStream;
       x : real;
begin
  St := TMemoryStream.Create;
  St.LoadFromFile('teste.str');
  Celula1.SetStream(St);
  Label2.Caption := 'String: '+Celula1.GetValor;
  if Celula1.GetFloat(x)then
  Label3.Caption := 'Float: '+FloatToStr(x);
end;

procedure TForm1.BtnPlailhaClick(Sender: TObject);
begin
  StGridDados.RowCount := StrToInt(Edit3.Text)+1;
  StGridDados.ColCount := StrToInt(Edit2.Text)+1;
  StGridDados.Visible := true;
  StGridDados.Cells[0,0] := 'Lin\Col';
end;

end.
